/*    */ package com.zimbra.cs.mailclient.imap;
/*    */ 
/*    */ import java.io.IOException;
/*    */ import java.io.PrintStream;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class PerfTest
/*    */ {
/*    */   private final int count;
/*    */   private final List<ImapConnection> connections;
/*    */   
/*    */   public PerfTest(int count)
/*    */   {
/* 28 */     this.count = count;
/* 29 */     this.connections = new ArrayList(count);
/*    */   }
/*    */   
/*    */   public void run() throws IOException {
/* 33 */     for (int i = 0; i < this.count; i++) {
/* 34 */       ImapConnection connection = newConnection();
/* 35 */       if (connection == null) break;
/* 36 */       this.connections.add(connection);
/*    */     }
/* 38 */     p("Created %d out of %d connections", new Object[] { Integer.valueOf(this.connections.size()), Integer.valueOf(this.count) });
/*    */   }
/*    */   
/*    */   private static ImapConnection newConnection() throws IOException {
/* 42 */     ImapConfig config = new ImapConfig();
/* 43 */     config.setHost("localhost");
/* 44 */     config.setPort(7143);
/* 45 */     config.setAuthenticationId("user1");
/* 46 */     ImapConnection connection = new ImapConnection(config);
/*    */     try {
/* 48 */       connection.connect();
/*    */     } catch (IOException e) {
/* 50 */       return null;
/*    */     }
/* 52 */     connection.login("test123");
/* 53 */     connection.select("INBOX");
/* 54 */     connection.noop();
/* 55 */     return connection;
/*    */   }
/*    */   
/*    */   private static void p(String fmt, Object... args) {
/* 59 */     System.out.println(String.format(fmt, args));
/*    */   }
/*    */   
/*    */   public static void main(String[] args) throws Throwable {
/* 63 */     int count = args.length > 0 ? Integer.parseInt(args[0]) : 100;
/* 64 */     PerfTest test = new PerfTest(count);
/* 65 */     test.run();
/* 66 */     Thread.sleep(1000000000L);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailclient/imap/PerfTest.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */